Skip to content

add test for fmod #301

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 13, 2025
Merged

add test for fmod #301

merged 3 commits into from
Aug 13, 2025

Conversation

spall
Copy link
Collaborator

@spall spall commented Jul 25, 2025

Add test for half and float versions of fmod.
closes #172

- Name: ExpectedOut0
Format: Float32
Stride: 16
Data: [ 0.2, -0.990005, 0, 0.25, 0, 2.1154, 0.2, -0.990005, 0, 0.25, 0, 2.1154, 0.2, -0.98999, 0, 0.25 ]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to remove the ...00005, since epsilon is sufficiently large

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also -0.98999 is strange, expected -.99

Format: Float16
Stride: 8
Data: [ 0x3800, 0xB780, 0x0, 0x3400, 0x0, 0x0, 0x3800, 0xB780, 0x0, 0x3400, 0x0, 0x0, 0x3800, 0xB800, 0x0, 0x3400 ]
# 0.5, -0.46875, 0, 0.25, 0, 0, 0.5 -0.46875, 0, 0.25, 0, 0, 0.5, -0.46875, 0, 0.25
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expected 10.5 mod 1.1 to be 0.6, I'm surprised 0.5 is the answer? It also doesn't seem like epsilon is high enough to tolerate this error, I'm surprised this is passing.
Also shocked at how far off -99.5 mod -3 is from .5, should we add -Gis to the compilation options perhaps to improve precision?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah the comment on the value was wrong, it was 1 not 1.1; Added Gis and have set the reuslt to -.5

Comment on lines 10 to 15

Out0[0] = fmod(In0[0], In1[0]);
Out0[1] = half4(fmod(In0[1].xyz, In1[1].xyz), fmod(In0[1].w, In1[1].w));
Out0[2] = half4(fmod(In0[2].xy, In1[2].xy), fmod(In0[2].zw, In1[2].zw));
Out0[3] = fmod(half4(10.5, -99.5, 5, 0.25), half4(1, -3, 0.25, 5));
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
Out0[0] = fmod(In0[0], In1[0]);
Out0[1] = half4(fmod(In0[1].xyz, In1[1].xyz), fmod(In0[1].w, In1[1].w));
Out0[2] = half4(fmod(In0[2].xy, In1[2].xy), fmod(In0[2].zw, In1[2].zw));
Out0[3] = fmod(half4(10.5, -99.5, 5, 0.25), half4(1, -3, 0.25, 5));
}
Out0[0] = fmod(In0[0], In1[0]);
Out0[1] = half4(fmod(In0[1].xyz, In1[1].xyz), fmod(In0[1].w, In1[1].w));
Out0[2] = half4(fmod(In0[2].xy, In1[2].xy), fmod(In0[2].zw, In1[2].zw));
Out0[3] = fmod(half4(10.5, -99.5, 5, 0.25), half4(1, -3, 0.25, 5));
}

Copy link
Contributor

@bob80905 bob80905 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@spall spall merged commit 4aeeadd into llvm:main Aug 13, 2025
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add test for fmod
3 participants